﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ChinessChess
{
    class CTuong:CQuanCo
    {
        private int new_Index, old_Index;
        int[] white = new int[7] {2,6,18,22,26,38,42 };
        int[] black = new int[7] {83,87,63,67,71,51,47 };
        public CTuong() { 

        }

        public CTuong(COCo []chess,int newIndex, int oldIndex, ChessColor color)
            : base(chess, color)
        {
            this.new_Index = newIndex;
            this.old_Index = oldIndex;
        }
        
        /// <summary>
        /// Kiem tra vi tri di co hop le hay khong
        /// </summary>
        /// <returns></returns>
        public override bool CheckIndex(){
            switch (Color) {
                case ChessColor.white: {
                    if (white.Contains(new_Index)) {
                        if (Math.Abs(new_Index - old_Index) == 16 || Math.Abs(new_Index - old_Index) == 20) {
                            return true;
                        }
                    }
                    break;
                }
                case ChessColor.black:{
                    if (black.Contains(new_Index))
                    {
                            if (Math.Abs(new_Index - old_Index) == 16 || Math.Abs(new_Index - old_Index) == 20){
                                return true;
                            }
                        }
                        break;
                    }
                
            }
            return false;
        }

        public override bool CheckPoint(){
            return !this.flag[(new_Index+old_Index)/2].State;
        }

    }
}
